const path = require("path");
const HtmlWebpackPlugin = require("html-webpack-plugin");
// const CopyPlugin = require("copy-webpack-plugin");
// const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const HelloPlugin = require("./plugins/hello-plugin");
const MyCleanPlugin = require("./plugins/my-clean-plugin");
const MyCopyWebpackPlugin = require("./plugins/my-copy-plugin");
const ZipAssetsPlugin = require("./plugins/zip-assets-plugin");

module.exports = {
  entry: "./src/index.js",

  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "bundle.[contenthash].js",
    clean: true,
  },

  mode: "production",

  module: {
    rules: [{ test: /\.txt$/, use: "raw-loader" }],
  },
  //   plugins: [new HtmlWebpackPlugin()],
  plugins: [
    new HtmlWebpackPlugin({ template: "./src/index.html" }),
    // new HelloPlugin(),
    // new CleanWebpackPlugin(),
    // new MyCleanPlugin(),
    // new MyCopyWebpackPlugin({
    //   patterns: [
    //     { from: "./assets/1.txt", to: "assets" },
    //     { from: "./assets/2", to: "assets" },
    //     { from: "./assets/bundle.js", to: "" },
    //   ],
    // }),
    // new CopyPlugin({
    //   patterns: [{ from: "./assets/1.txt", to: "assets" }],
    // }),

    new ZipAssetsPlugin({
      filename: "compress",
    }),
  ],
};
